      SUBROUTINE QUIKVIS5W(INODE,SEGCIRC,NOVERLAP,OVERLAP,SOMETRUE)
      IMPLICIT REAL*8 (A-H,O-Z)
C
C THIS ROUTINE IS PART OF THE QUIKVIS PROGRAM.  IT CREATES AN ARRAY,
C SEGCIRC, OF TRUE/FALSE FLAGS INDICATING WHERE, IN A 2PI RANGE,
C OBSERVATION CONSTRAINTS ARE SATISFIED.  QUIKVIS PROCESSES A SEQUENCE
C OF ORBIT RAANS AND (NORMALLY) THIS ROUTINE IS CALLED ONCE FOR EACH
C RAAN.  THE SEGCIRC ARRAY IS MODIFIED EACH TIME TO REPRESENT COMMON
C MEAN ANOMALY RANGES WHERE THE CONSTRAINTS ARE SATISFIED FOR ALL
C RAANS PROCESSED.
C
C IN MEAN ANOMALY, THERE ARE NOVERLAP MEAN ANOMALY SEGMENTS, DEFINED IN
C THE OVERLAP ARRAY, WHERE THE REQUIREMENTS ARE SATISFIED.  THE 2PI
C RANGE IS DIVIDED INTO MAXSEGCIRC(A PARAMETER IN QUIKVIS.INC) AND
C EACH SEGMENT HAS A TRUE/FALSE FLAG ASSIGNED ACCORDING TO WHETHER THE
C REQUIREMENTS ARE SATISFIED THERE.
C
C
C VARIABLE DIM TYPE I/O DESCRIPTION
C -------- --- ---- --- -----------
C
C INODE     1   I*4  I  THE CALL NUMBER IN THE CURRENT SEQUENCE OF
C                       CALLS.  IF =1, THE SEGCIRC ARRAY IS
C                       REINITIALIZED BEFORE THE OVERLAP ARRAY IS
C                       CONSIDERED.
C
C SEGCIRC       L*1 I/O DESCRIBED IN THE INTRODUCTORY COMENTS ABOVE.
C     MAXSEGCIRC
C
C NOVERLAP  1   I*4  I  THE NUMBER OF ANGLE PAIRS IN THE OVERLAP ARRAY.
C                       IF ZERO, THEN TARGET IS NOT AVAILABLE.
C
C OVERLAP       R*8  I  OVERLAP(1,I) IS THE MEAN ANOMALY FOR THE I'TH
C     2,MAXREQMT        PAIR WHERE TARGET AVAILABILITY BEGINS;
C                       OVERLAP(2,I) IS WHERE IT CEASES.  IN RADIANS.
C
C SOMETRUE  1   L*4  O  INDICATES WHETHER AT LEAST ONE SEGCIRC ELEMENT
C                       IS TRUE.  =T, AT LEAST ONE;  =F, NONE ARE TRUE.
C
C***********************************************************************
C
C BY C PETRUZZO/GFSC/742.   9/86.
C       MODIFIED....
C
C***********************************************************************
C
      INCLUDE 'QUIKVIS.INC'
C
      REAL*8 OVERLAP(2,MAXREQMT)
      LOGICAL*1 SEGCIRC(MAXSEGCIRC),SEGSTEMP(MAXSEGCIRC)
      REAL*8 DELSEG/0.D0/
      LOGICAL SOMETRUE
C
C
      IBUG = 0
      LUBUG = 19
C
      IF(IBUG.NE.0) WRITE(LUBUG,8001) NOVERLAP,
     *         (OVERLAP(1,J)*DEGRAD,OVERLAP(2,J)*DEGRAD,
     *              J=1,MAX(1,NOVERLAP))
 8001 FORMAT(
     *  ' QUIKVIS5W DEBUG 8001.    NOVERLAP=',I2,'   OVERLAP='/,
     *   <MAX(1,NOVERLAP)>(T12,2(F9.3,', ')/))
C
C
C INTIALIZE.
C
      NSEGCIRC = MAXSEGCIRC
      DELCIRC = TWOPI/NSEGCIRC
      IF(IBUG.NE.0) WRITE(LUBUG,5649) NSEGCIRC,DELCIRC*DEGRAD
 5649 FORMAT(' QUIKVIS5W. DEBUG 5649. NSEGCIRC,DELCIRC=',I5,G13.5)
 
C    IF THIS IS THE FIRST CALL OF THE SERIES, SET THE INTERVAL FLAGS TO
C    INDICATE THE ENTIRE TWOPI RANGE IS AVAILABLE.  SUBSEQUENT CODE MAY
C    CHANGE SOME OF THE FLAGS TO FALSE WHEN THE OVERLAP ARRAY IS
C    CONSIDERED.
C
      IF(INODE.EQ.1) THEN
        DO I=1,NSEGCIRC
          SEGCIRC(I) = .TRUE.
          END DO
        END IF
C
C SET THE INTERVAL FLAGS.  FIRST, SET AN INTERNAL ARRAY SHOWING THE
C SPANS OF ADJUSTED(BY EVENTMA IN QUIKVIS5A2C) MEAN ANOMALIES WHERE THE
C TARGET IS AVAILABLE.  NEXT, REDEFINE THE SEGCIRC ARRAY SHOWING WHERE
C THE OK RANGES OUTPUT FROM THE PREVIOUS CALL(AS INDICATED BY THE
C CONTENTS OF SEGCIRC INPUT ON THIS CALL) AND THE OK RANGES AS INDICATED
C IN THE OVERLAP ARRAY COINCIDE.
C
      IF(NOVERLAP.EQ.0) THEN
C
C      THERE ARE NO OK RANGES IN OVERLAP, SO THERE ARE NO OK RANGES
C      WHERE SEGCIRC AND OVERLAP COINCIDE.  THEREFORE, ALL SEGCIRC
C      ELEMENTS ARE FALSE.
        DO I=1,NSEGCIRC
          SEGCIRC(I) = .FALSE.
          END DO
        SOMETRUE = .FALSE.
        GO TO 9999
C
      ELSE   ! NOVERLAP > 0
C
        DO ISEG=1,NSEGCIRC
          SEGSTEMP(ISEG) = .FALSE.
          END DO
C
        DO ILAP=1,NOVERLAP
          ANG1 = EQVANG( OVERLAP(1,ILAP) )
          ANG2 = EQVANG( OVERLAP(2,ILAP) )
          INDEX1 = ANG1/DELCIRC + 1
          NSET = JIDNNT( EQVANG(ANG2-ANG1) / DELCIRC )
          IF(IBUG.NE.0) WRITE(LUBUG,5650) ILAP,ANG1*DEGRAD,ANG2*DEGRAD,
     *           INDEX1,NSET,INDEX1+NSET-1
 5650     FORMAT(' QUIKVIS5W DEBUG 5650.  ILAP=',I2/,
     *           '    ANG1,ANG2=',2F9.3,'  INDEX1,NSET,INDEX1+NSET-1=',
     *             3I6)
          DO ISET=1,NSET
            INDEX = INDEX1 + ISET - 1
            IF(INDEX.GT.NSEGCIRC) INDEX = INDEX-NSEGCIRC ! CROSSES 360
            SEGSTEMP(INDEX) = .TRUE.
            END DO
          END DO
C
        IF(IBUG.NE.0) THEN
          KSKIP = 40
          WRITE(LUBUG,5655)
     *         (SEGSTEMP((I-1)*KSKIP+1),I=1,90),
     *         (MOD(I-1,10),I=1,10)
 5655     FORMAT(' QUIKVIS5W. DEBUG 5655.'/,
     *         '  SEGSTEMP=',90L1/,
     *         '           ',10(I1,'    .    '))
          END IF
C
        SOMETRUE = .FALSE.
        DO I=1,NSEGCIRC
          SEGCIRC(I) = SEGCIRC(I) .AND. SEGSTEMP(I)
          SOMETRUE = SOMETRUE .OR. SEGCIRC(I)
          END DO
C
        END IF  ! ENDS THE 'IF(NOVERLAP.EQ.0)...ELSE...' BLOCK
C
 9999 CONTINUE
      RETURN
C
C***********************************************************************
C
C
C**** INITIALIZATION CALL. PUT GLOBAL PARAMETER VALUES INTO THIS
C     ROUTINE'S LOCAL VARIABLES.
C
      ENTRY QVINIT5W
C
      CALL QUIKVIS999(-1,R8DATA,I4DATA,L4DATA)
      RETURN
C
C***********************************************************************
C
      END
